﻿using Architecture.API.Application.Command.RequestForLeaveCommand;
using Architecture.Domain.Dto.LeaveDto;
using Architecture.Domain;
using MediatR;
using Architecture.Domain.Service.LeaveServices;

namespace Architecture.API.Application.CommandHandlers.RequestForLeaveHandler
{
    /// <summary>
    /// 请假分页命令处理器
    /// </summary>
    public class LeaveListSeachCommandHandler : IRequestHandler<LeaveListSeachCommand, LeaveListDto<GetInfoDto>>
    {
        /// <summary>
        /// 请假服务
        /// </summary>
        protected readonly ILeaveService _leaveService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="leaveService">请假服务</param>
        public LeaveListSeachCommandHandler(ILeaveService leaveService)
        {
            _leaveService = leaveService;
        }

        /// <summary>
        /// 请假分页列表
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>返回请假分页列表信息</returns>
        public async Task<LeaveListDto<GetInfoDto>> Handle(LeaveListSeachCommand request, CancellationToken cancellationToken)
        {
            return await _leaveService.GetLeaveList(request.UserId,request.PageIndex,request.PageSize,request.UserName,request.ToExamine);
        }
    }
}
